package com.tengfei.blogsystem.controller.admin;

/**
 * @version v1.0
 * @author} feige
 * @date 2021-10-15-16:22
 * @description
 */

import com.tengfei.blogsystem.response.ResponseResult;
import com.tengfei.blogsystem.service.IWebSiteInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 网站信息api
 */
@PreAuthorize("@permission.admin()")    //需要管理员权限
@RestController
@RequestMapping("/admin/web_info")
public class WebSiteInfoAdminApi {

    @Autowired
    private IWebSiteInfoService webSiteInfoService;

    /**
     * 获取网站标题
     *
     * @param
     * @return
     */
    @GetMapping("/title")
    public ResponseResult getWebTitle() {
        return webSiteInfoService.getWebTitle();
    }

    /**
     * 修改网站标题
     *
     * @param title
     * @return
     */
    @PutMapping("/{title}")
    public ResponseResult updateWebTitle(@PathVariable("title") String title) {
        return webSiteInfoService.updateWebTitle(title);
    }

    /**
     * 获取网站seo信息
     *
     * @param
     * @return
     */
    @GetMapping("/seo")
    public ResponseResult getWebSeo() {
        return webSiteInfoService.getWebSeo();
    }

    /**
     * 修改网站seo信息
     *
     * @param keywords
     * @param description
     * @return
     */
    @PutMapping("/seo/{keywords}/{description}")
    public ResponseResult updateWebSeo(@PathVariable("keywords") String keywords, @PathVariable("description") String description) {
        return webSiteInfoService.updateWebSeo(keywords, description);
    }

    /**
     * 获取网站统计信息
     *
     * @param
     * @return
     */
    @GetMapping("/view_count")
    public ResponseResult getWebViewCount() {
        return webSiteInfoService.getWebViewCount();
    }
}
